package com.lifq.flink

import java.sql.DriverManager

/**
 * @Author: LiFuqiang
 * @Date: 2023/10/10 13:51
 * @Version 1.0 
 * @description
 */
object DorisSink {
  def main(args: Array[String]): Unit = {
    val jdbc = "jdbc:mysql://10.0.127.81:29030/sybd_sense" +
      "?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false" +
      "&serverTimezone=Asia/Shanghai&tinyInt1isBit=true&useAffectedRows=true&nullCatalogMeansCurrent=true" +
      "&useInformationSchema=true&useCursorFetch=true"
    Class.forName("com.mysql.cj.jdbc.Driver")
    val connection = DriverManager.getConnection(jdbc,"root","CMZyv_ruREMsFO0ltEB")
    val id = "19999"
    val crateUserId = "20"
    var result: Map[String, Any] = Map("rowTotal" -> 1, "scanTotal" -> 2,
      "completeTotal" -> 3,
      "incompleteTotal" -> 4)
    val str = JsonUtil.toJson(result)
    println(str)
    val sql = String.format("insert into data_quality_metrics(id, crateUserId,result) values(%s, %s,'%s')", id,crateUserId,JsonUtil.toJson(result))
    println(sql)
    val stmt = connection.prepareStatement(sql)
    stmt.execute()
    connection.close()
  }
}
